#include "user_scope.h"

#define MCU_MCLK_48MHZ      // MCU_MCLK_24MHZ  MCU_MCLK_48MHZ
/*******************mcu and pwm set********************************/
#if defined(MCU_MCLK_48MHZ)
#define MCU_MCLK             (48000000LL)       /* MCU时钟频率 */
#elif defined(MCU_MCLK_24MHZ)
#define MCU_MCLK             (24000000LL)       /* MCU时钟频率 */
#endif
#define PWM_MCLK             ((u32)MCU_MCLK)    /* PWM时钟频率 */
#define PWM_PRSC             ((u8)0)            /* PWM预分频*/
#define PWM_FREQ             ((u16)16000)        /* PWM斩波频率 */
#define PWM_DEATIME_US       (1.0)              /* PWM死区时间us */
#define TIME0_PREIOD_VALUE   ((u32)(MCU_MCLK/2000 - 1))    /*timer0定时500us=2000hz装载值*/
/*******************adc set********************************/
#define ADC_VDD_VEF          (2.5)   //Unit:v
#define ADC_RS_SAMPLE        (0.05)  //Unit:ohm
#if defined(DEMO_BOARD)
#define ADC_PGA_GAIN         (1<<PGA_AMP_GAIN16)    //Unit:none 串20k电阻
#define HAREWARE_IMAX       (((float)ADC_VDD_VEF/(ADC_RS_SAMPLE*ADC_PGA_GAIN*0.5))) //Unit:A
#elif defined(DPM_PIN16_DOUBLE_RS)
#define ADC_PGA_GAIN         (1<<PGA_AMP_GAIN16)    //Unit:none 串1k电阻
#define HAREWARE_IMAX        (((float)ADC_VDD_VEF/(ADC_RS_SAMPLE*ADC_PGA_GAIN))) //Unit:A
#elif defined(DPM_PIN16_SINGLE_RS)
#define ADC_PGA_GAIN         (1<<PGA_AMP_GAIN8)    //Unit:none 串1k电阻
#define HAREWARE_IMAX        (((float)ADC_VDD_VEF/(ADC_RS_SAMPLE*ADC_PGA_GAIN))) //Unit:A
#elif defined(DPM_PIN24_DOUBLE_RS)
#define ADC_PGA_GAIN         (1<<PGA_AMP_GAIN16)    //Unit:none 串20k电阻
#define HAREWARE_IMAX       (((float)ADC_VDD_VEF/(ADC_RS_SAMPLE*ADC_PGA_GAIN*0.5))) //Unit:A
#endif

/*******************motor set********************************/
#define MOTOR_IDENTIFY_ENABLE 0   //0:禁止辨识，需手动输入参数；1：使能辨识，填入辨识结果

#define MOTOR_PM_FLUX        (1.0)  //Unit:Wb
#define MOTOR_INERTIA        (1.0)  //Unit:Kg.m^2
/*******************系统功能配置 set********************************/
#define MIDDLE_FREQUENCY_TASK_MS   20   //中频任务周期:ms
#define LOW_FREQUENCY_TASK_MS      (2)//低频任务周期

// 位置检测方式
#define DEFAULT_VELOCITY_SENSOR 0
#if DEFAULT_VELOCITY_SENSOR == 0
		#define VS_SMO
#elif DEFAULT_VELOCITY_SENSOR == 1
    #define VS_FO
#endif

// 启动策略
#define START_TRATEGY 3 
#if START_TRATEGY == 0
#elif START_TRATEGY == 1
    #define ROTOR_INITIAL_POSITION_DETECT
#elif START_TRATEGY == 2
    #define ROTOR_INITIAL_POSITION_DETECT
#elif START_TRATEGY == 3
    #define ROTOR_INITIAL_POSITION_DETECT
    #define ON_THE_FLY_STATE                
#endif                         
/*******************用户 set********************************/

#define OBSERVER_GAIN_SWITCH_TIME (15.0) //系统增益切换滤波时间ms


///*******************end set********************************/